package sqlist;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

public class TestDemo {

    public static List<Character> func(String s1, String s2){
        List<Character> ret = new ArrayList<>();
        for(int i = 0; i < s1.length();i++){
            char ch = s1.charAt(i);
            if(!s2.contains(ch+"")){
                ret.add(ch);
            }
        }
        return ret;
    }

    public static void main(String[] args) {
        String s1 = "welcometobit";
        String s2 = "come";
        List<Character> ret = func(s1, s2);
        System.out.println(ret);
        System.out.println("===========");
        for (char ch:
             ret) {
            System.out.print(ch);
        }
        System.out.println();
    }

    public List<List<Integer>> generate(int numRows){
        List<List<Integer>> ret = new ArrayList<>();
        List<Integer> one = new ArrayList<>();
        one.add(1);//第一排的只存一个1就行
        ret.add(one);
        //i代表每一行
        for(int i = 1; i < numRows; i++){
            List<Integer> curRow = new ArrayList<>();
            //这一行开始的1
            curRow.add(1);
            List<Integer> preRow = ret.get(i-1);
            for(int j = 1; j < i; j++){
                int x = preRow.get(j) + preRow.get(j-1);
                curRow.add(x);
            }
            curRow.add(1);
            ret.add(curRow);
        }
        return ret;

    }
    //LeetCode杨辉三角
    public static void main5(String[] args) {
        List<Integer> arrayList = new ArrayList<>();
        List<Integer> arrayList2 = new ArrayList<>();
        List<List<Integer>> arrayList3 = new ArrayList<>();
    }
    public static void main4(String[] args) {
        ArrayList<Integer> arrayList = new ArrayList<>();
        arrayList.add(0,1);
        arrayList.add(1, 2);
        arrayList.add(2,199);
        arrayList.add(3, 299);
        arrayList.add(4, 399);
        System.out.println(arrayList);
        System.out.println("-=========");
        for(int i = 0; i < arrayList.size(); i++){
            System.out.print(arrayList.get(i) + " ");
        }
        System.out.println();
        System.out.println("=============");
        for (Integer x :
                arrayList) {
            System.out.print(x + " ");
        }
        System.out.println();
        System.out.println("=========迭代器使用===");
        Iterator<Integer> it = arrayList.iterator();
        while(it.hasNext()){
            System.out.print(it.next() + " ");
        }
        System.out.println();
        System.out.println("=====迭代器使用2====");
        Iterator<Integer> it2 = arrayList.listIterator();
        while(it2.hasNext()){
            System.out.print(it2.next()+" ");
        }
    }

    public static void main2(String[] args) {
        ArrayList<Integer> arrayList = new ArrayList<>();
        arrayList.add(1);//往数组最后一个位置存元素
        arrayList.add(2);
        arrayList.add(3);
        arrayList.add(4);
        System.out.println(arrayList.size());//获取当前的有效数据的个数
        System.out.println(arrayList.get(1));//获取1下标的元素
        System.out.println("==========");
        ArrayList<Integer> arrayList1 = new ArrayList<>(arrayList);
        arrayList1.add(99);
        arrayList1.add(199);
        System.out.println(arrayList1);
        ArrayList<Integer> arrayList2 = new ArrayList<>(15);
        //System.out.println(arrayList2);

    }
    public static void main1(String[] args) {
        MyArraylist myArraylist = new MyArraylist();
        myArraylist.add(5,1);
        myArraylist.disply();
    }

}
